package app.view.mediators
{
	import app.AppConstants;
	import app.controller.core.FlushFlareDataCmd;
	
	import flash.events.MouseEvent;
	
	import mx.containers.ApplicationControlBar;
	
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;

	public class ControlBarMediator extends Mediator
	{
		public static const NAME:String = "ControlBarMediator"
		public function ControlBarMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);
		}
		
		override public function onRegister():void{
			view.addEventListener(MouseEvent.CLICK, onClick);			
		}
		
		private function onClick( event:MouseEvent ):void{
			if(event.currentTarget === event.target)return;
			switch(event.target.name){
				case "updateCB":
					sendNotification( AppConstants.TOGGLE_AUTO_UPDATE, event.target.selected );
					break;
					
				case "updateBtn":
					sendNotification( AppConstants.UPDATE_VISUALISATION );
					break;
					
				case "flushData":
					sendNotification( AppConstants.FLUSH_FLARE_DATA, FlushFlareDataCmd );
					break;
					
					
			}
		}
		
		/* override public function listNotificationInterests():Array{
			return [		]
		}
		
		override public function handleNotification(note:INotification):void{
			
			switch( note.getName() ){
				
				case FlareDataProxy.FLARE_DATA_POPULATED:
					view.dataProvider = Data( note.getBody() );
					break;
					
			
				
			}
		}
 */		
		private function get view():ApplicationControlBar{
			return ApplicationControlBar(viewComponent);
		}
		
	}
}